package org.xue.snowmall.bargain.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xue.snowmall.bargain.entity.BargainRecordEntity;
import org.xue.snowmall.bargain.service.BargainRecordService;
import org.xue.snowmall.bargain.service.HelpRecordService;
import org.xue.snowmall.common.utils.R;

/**
 * @author 小刘的小张
 * @version 1.0
 * @description: TODO
 * @date 2021/9/26 14:51
 */
@Controller
public class WebHelpRecordController {

    @Autowired
    private HelpRecordService helpRecordService;

    @Autowired
    private BargainRecordService bargainRecordService;

    @RequestMapping("/saveHelpRecord")
    @ResponseBody
    public R saveHelpRecord(@RequestParam("gsmBargainRecordId") Long gsmBargainRecordId) {

        return helpRecordService.saveHelpRecord(gsmBargainRecordId);
    }

    @RequestMapping("toSaveHelpRecord")
    public String toSaveHelpRecord(@RequestParam("gsmBargainRecordId") Long gsmBargainRecordId
            , Model model) {

        //查出当前砍价id所对应的值
        BargainRecordEntity byId = bargainRecordService.getById(gsmBargainRecordId);
        model.addAttribute("bre",byId);
        return "helpBargain";
    }
}
